<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@include file="/static/common/taglib.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
    <title>派班历史记录</title>
    <%@include file="../../public/commonCss.jsp" %>
    <%@include file="../../public/commonJs.jsp" %>
</head>
<body ms-controller="main" class="ms-controller">
<div id="wrapper">
    <div class="boxtoolbar whiteBox actionArea contentbox">
        <div class="layui-inline">
            <div class="layui-input-inline">
                <input type="text" class="layui-input Wdate js_start" style="height: 32px"
                       ms-duplex="searchKey.workDate"
                       onClick="WdatePicker({readOnly:true})"/>
            </div>
        </div>
        <div class="layui-inline">
            <div class="layui-input-inline">
                <input type="text" style="height: 32px;width: 200px" ms-duplex="searchKey.searchKey"
                       placeholder="搜索、人员姓名、人员编号"
                       class="layui-input"/>
            </div>
        </div>
        <div class="layui-inline">
            <div class="layui-input-inline">
                <button class="layui-btn layui-btn-normal layui-btn-small" ms-on-click="searchData()">搜索</button>
                <button class="layui-btn layui-btn-small"
                        onclick="exportExcel()">派班导出
                </button>
            </div>
        </div>
    </div>
    <div class="boxmain whiteBox lrbox" style="margin-top:-90px">
        <div class="lrboxmain borderL" style="margin-left:0%">
            <div class="from-body contentbox" style=" overflow: auto;">
                <table class="layui-table">
                    <thead>
                    <tr>
                        <th>行号</th>
                        <th>人员编号</th>
                        <th>人员姓名</th>
                        <th>交路名称</th>
                        <th>车组号</th>
                        <th>派班日期</th>
                        <th>叫班时间</th>
                        <th>是否已叫班</th>
                        <th>有无应答</th>
                        <th>登录时间</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr ms-repeat="tableDatas">
                        <td>{{(currentPage-1)*pageSize+$index+1}}</td>
                        <td>{{el.userNum}}</td>
                        <td>{{el.userName}}</td>
                        <td>{{el.roadName}}</td>
                        <td>{{el.trainNum}}</td>
                        <td>{{el.workDate}}</td>
                        <td>{{el.remindTime}}</td>
                        <td>
                            <span ms-if="el.hadRemind=='0'" style="color: #ed6a65">未叫班</span>
                            <span ms-if="el.hadRemind=='1'" style="color: #6366ed">已叫班</span>
                        </td>
                        <td>
                            <span ms-if="el.hadResp=='0'" style="color: #ed6a65">无应答</span>
                            <span ms-if="el.hadResp=='1'" style="color: #6366ed">已应答</span>
                        </td>
                        <td style="color: #6366ed">{{el.respTime}}</td>
                    </tr>
                    </tbody>
                </table>
                <!-- 分页 -->
                <div id="demo" class="fenye">
                </div>
            </div>
        </div>
    </div>
    <!-- whitebox -->
</div>
<script type="text/javascript">
    var vm;
    avalon.ready(function () {
        vm = avalon.define({
            $id: "main",
            tableDatas: [],//图片数据
            currentPage: 1,
            pageSize: 15,
            searchKey: {
                searchKey: "",
                workDate: "${startDate}"//记录日期
            }
        })
        avalon.scan();
        loadTableData(1);
    });

    //导出excel
    function exportExcel() {
        window.location.href = "${ctx}/giveWorkExport/exportGiveWorks.action?startDate=" + $(".js_start").val();
    }

    function searchData() {
        loadTableData(1);
    }

    //加载表格数据
    function loadTableData(curr) {
        var dataStr = vm.$model.searchKey;
        dataStr.currentPage = vm.$model.currentPage;
        dataStr.pageSize = vm.$model.pageSize;
        $.ajax({
            type: 'post',
            url: '${ctx}/giveWorkController/selectOnePage.action',
            data: dataStr,
            dataType: "json",
            timeout: 10000,
            beforeSend: function () {
                layui.layer.msg('正在加载...', {time: 0, icon: 16, shade: 0.02});
            },
            success: function (data) {
                closeDialog();
                vm.tableDatas = data.result;
                layui.laypage({
                    cont: 'demo',
                    pages: data.totalPage,
                    curr: curr || 1, //当前页
                    skip: true,
                    skin: '#1E9FFF',
                    jump: function (obj, first) {
                        if (!first) {
                            vm.currentPage = obj.curr;
                            loadTableData(obj.curr);
                        }
                    }
                });
            }
        });

    }
</script>
</body>
</html>